import com.itheima.domain.Account;
import com.itheima.service.AccountService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

public class App {
    public static void main(String[] args) {
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        AccountService accountService = ctx.getBean("accountService",AccountService.class);
        /*Account ac = accountService.findById(1);
        System.out.println(ac);*/

        // 测试新增
       // Account account = new Account();
       // account.setName("Tom");
       // account.setMoney(123456.78);
       //
       // accountService.save(account);

        // 查询所有
        List<Account> all = accountService.findAll();
        for (Account account : all) {
            System.out.println(account);
        }

        // 删除
        accountService.delete(4);



        // 修改
        Account account = new Account(3,"Jack",12345.7);
        accountService.update(account);

        List<Account> list = accountService.findAll();
        for (Account ac : list) {
            System.out.println(ac);
        }

    }
}
